package com.echo.im.storage.backup.mq;


import cn.hutool.core.bean.BeanUtil;
import com.echo.im.common.vo.message.SystemMessageVO;
import com.echo.im.mq.contant.QueueConstants;
import com.echo.im.mq.event.receiver.AbstractMessageReceiver;
import com.echo.im.repository.dao.entity.SystemMessage;
import com.echo.im.repository.dao.mapper.SystemMessageMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 私聊消息存储队列消费者
 * @author echo
 */
@Component
@Slf4j
@RequiredArgsConstructor
public class SystemStorageMessageReceiver extends AbstractMessageReceiver<SystemMessageVO> {

    private final SystemMessageMapper systemMessageMapper;

    @Override
    public void doReceive(SystemMessageVO data) {
        SystemMessage systemMessage = BeanUtil.copyProperties(data, SystemMessage.class);
        systemMessageMapper.insert(systemMessage);
    }

    @Override
    public String getQueueName() {
        return QueueConstants.STORE_SYSTEM_QUEUE;
    }
}
